package com.original.simuladoresws.controller;

import java.util.List;

import org.springframework.stereotype.Controller;

import com.original.simuladoresws.entities.TbSimulation;
import com.original.simuladoresws.entities.soap.SOAPObjectiveSimulationsGetListInput;
import com.original.simuladoresws.entities.soap.SOAPObjectiveSimulationsGetListOutput;
import com.original.simuladoresws.service.SimulationService;
import com.original.simuladoresws.service.impl.SimulationServiceImpl;

@Controller
public class ObjectiveSimulationsGetListController {
	SimulationService simulationService = new SimulationServiceImpl();
	public SOAPObjectiveSimulationsGetListOutput objectiveSimulationsGetList(SOAPObjectiveSimulationsGetListInput input) {
		SOAPObjectiveSimulationsGetListOutput output = new SOAPObjectiveSimulationsGetListOutput();
		List<TbSimulation> simulations = simulationService.getAllSimulation();
		try {
			int totalRecord = simulations.size();
			output.setError(false);
			output.setMessage("");
			output.setSimulations(simulations);
			output.setCurrent_page(input.getPag_CurrentPage());
			output.setTotal_items(totalRecord);
			output.setTotal_pages(totalRecord / input.getPag_Items() + 1);
			
		} catch (Exception e) {
			output.setError(true);
			output.setMessage("");
		}
		return output;
	}
}
